package com.ruibang.glass.equipment.controller;


import com.ruibang.glass.equipment.constant.Constants;
import com.ruibang.glass.equipment.domain.req.device.ElevatorReq;
import com.ruibang.glass.equipment.entity.device.Elevator;
import com.ruibang.glass.equipment.entity.device.ScrapReport;
import com.ruibang.glass.equipment.service.ElevatorService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 电梯服务
 * </p>
 *
 * @author mameng
 * @since 2024-03-20
 */
@RestController
@RequestMapping("/api/equipment/elevator")
@Api(value = "电梯")
public class ElevatorController {
    @Autowired
    private ElevatorService elevatorService;

    @PostMapping("list")
    @ApiOperation(value = "获取电梯列表", response = ResultBody.class)
    public ResultBody getBoilerList(@RequestBody ElevatorReq elevatorReq) {
        return ResultBody.success(elevatorService.queryElevatorlList(elevatorReq));
    }

    @PostMapping("/deleteById")
    @ApiOperation(value = "删除实体", response = ResultBody.class)
    public ResultBody deleteById(@RequestBody Elevator elevator) {
        elevatorService.lambdaUpdate().set(Elevator::getIsDelete, Constants.ONE_STR).eq(Elevator::getId, elevator.getId()).update();
        return ResultBody.success();
    }

    @PostMapping("/getPressureVesselById")
    @ApiOperation(value = "获取对象", response = ResultBody.class)
    public ResultBody getBoilerInfoById(@RequestBody Elevator elevator) {
        Elevator byId = elevatorService.getById(elevator.getId());
        return ResultBody.success(byId);
    }

    @PostMapping("/updateBoilerInfo")
    @ApiOperation(value = "更新", response = ResultBody.class)
    public ResultBody updateBoilerInfo(@RequestBody Elevator elevator) {
        return ResultBody.success(elevatorService.updateOrAddById(elevator));
    }

}
